package com.app.service.impl;

import com.app.mapper.FormMapper;
import com.app.mapper.FormRemarkMapper;
import com.app.model.FormModel;
import com.app.model.FormRemarkModel;
import com.app.service.FormRemarkService;
import com.app.service.FormService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
@Primary
public class FormRemarkServiceImpl implements FormRemarkService {
   @Autowired
    FormRemarkMapper formRemarkMapper;

    @Override
    public FormRemarkModel getRemarkById(int id) {
        QueryWrapper<FormRemarkModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("id", id);
        FormRemarkModel plantModel =  formRemarkMapper.selectOne(queryWrapper);
        if (plantModel == null) {
            return null;
        } else {
            return plantModel;
        }
    }

    @Override
    public FormRemarkModel getRemarkByFormId(int formId) {
        QueryWrapper<FormRemarkModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("form_id", formId);
        FormRemarkModel plantModel =  formRemarkMapper.selectOne(queryWrapper);
        return plantModel;
    }

    @Override
    public void update(FormRemarkModel model) {
        formRemarkMapper.updateById(model);
    }

    @Override
    public void insert(FormRemarkModel model) {
        formRemarkMapper.insert(model);
    }

    @Override
    public void delete(int id) {
        formRemarkMapper.deleteById(id);
    }


//    @Override
//    public Integer plantCount(List<Integer> idsList) {
//        QueryWrapper<PlantModel> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select("id");
//        if (idsList != null&&idsList.size()>0) {
//            queryWrapper.in("department_id", idsList);
//        }
//        Integer plantCount = plantMapper.selectCount(queryWrapper);
//        return plantCount;
//    }

//    @Override
//    public List<PlantModel> getStatisticsByIds(List<Integer> idList, String key) {
//        QueryWrapper<PlantModel> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select(key,"COUNT(*) as count");
//        if (idList.size() != 0) {
//            queryWrapper.in("department_id", idList);
//        }
//        queryWrapper.groupBy(key);
//        List<PlantModel> personModelList = plantMapper.selectList(queryWrapper);
//        return personModelList;
//    }
//
//    @Override
//    public List<PlantModel> getPlantByIds(List<Integer> idList) {
//        QueryWrapper<PlantModel> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select().in("id",idList);
//        List<PlantModel> personModelList = plantMapper.selectList(queryWrapper);
//        return personModelList;
//    }
}
